package com.huluobo.a2201mvvm_imdemo.chat;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.huluobo.a2201mvvm_imdemo.R;
import com.hyphenate.easeui.modules.chat.EaseChatFragment;

public class ChatActivity extends AppCompatActivity {
    private ChatFragment chatFragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_chat);

        TextView title = findViewById(R.id.header_title);
        String username = getIntent().getStringExtra("conversationId");
        title.setText("正在与" + username + "聊天");

        ImageView back = findViewById(R.id.header_back);
        back.setVisibility(View.VISIBLE);
        back.setOnClickListener(v -> {
            finish();
        });
        //use EaseChatFratFragment
        chatFragment = new ChatFragment();
        //pass parameters to chat fragment
        chatFragment.setArguments(getIntent().getExtras());
        getSupportFragmentManager().beginTransaction().add(R.id.container, chatFragment).commit();
    }
}